#pragma once
#include "IContext.h"

#include <string>
#include <memory>
using std::unique_ptr;
using std::wstring;

class OwinHost
{
public:
	OwinHost(void);
	~OwinHost(void);

	static OwinHost& instance();

	void startup(IContext* env);
	void shutdown();
	const wstring& root() const;

private:
	void startupOwin();
	void startupCLR();
	void shutdownOwin();
	void shutdownCLR();
	unsigned short getAvailablePort();

private:
	static unique_ptr<OwinHost> s_instance;

	wstring m_owin; // path of cockpit owin assembly
	wstring m_root; // string of root url, e.g. http://localhost:50000
	wstring m_startupUrl; // string of startup url, e.g. http://localhost:50000/index.html
	void* m_clr; // pointer to CLR host
};

